package com.lagou.rpc.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * SpringConfigUtils
 *
 * @author zyt
 * @since 2020/8/13 23:22
 */
@Component
public class SpringConfigUtils implements ApplicationContextAware {

    private static ApplicationContext context;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("初始化了。。。。");
        context = applicationContext;
    }

    public static ApplicationContext getContext() {
        return context;
    }

    public static Object getBean(Class<?> tClass) {
        return context.getBean(tClass);
    }
}
